package com.tydic.portal.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tydic.borderer.domain.BordererInfo;
import com.tydic.borderer.domain.bo.BordererDetailBo;
import com.tydic.borderer.domain.vo.BordererInfoVo;
import com.tydic.borderer.service.IBordererInfoService;
import com.tydic.common.core.domain.R;
import com.tydic.common.mybatis.core.page.TableDataInfo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * 边民信息
 */
@RestController
@RequestMapping("/portal/borderer")
@RequiredArgsConstructor
@Slf4j
public class BordererInfoController {

    private final IBordererInfoService bordererInfoService;

    /**
     * 获取边民信息
     *
     * @param id 边民id
     * @return
     */
    @GetMapping("getBordererInfo")
    public R<BordererInfoVo> getBordererInfoById(String id) {
        return R.ok(bordererInfoService.queryById(id));
    }

    /**
     * 查询边民信息列表
     *
     * @param request
     * @return
     */
    @PostMapping("getBordererInfoList")
    public R<TableDataInfo<BordererInfo>> getBordererDetailsList(@RequestBody BordererDetailBo request) {
        Page<BordererInfo> page = bordererInfoService.getBordererDetailsList(request);
        return R.ok(TableDataInfo.build(page));
    }

    /**
     * 审核边民信息
     *
     * @param borderId
     * @param comment
     * @param pass
     * @return
     */
    @PostMapping("approveBordererInfo")
    public R<Void> approveBordererInfo(String borderId, String comment, boolean pass) {
        bordererInfoService.approveBordererInfo(borderId, comment, pass);
        return R.ok("处理成功");
    }
}
